/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deatax.display;

/**
 *
 * @author Caroline
 */
public class Vector3f {
    public float x,y,z;
    
    public Vector3f(Vector3f v){
        x = v.x;
        y = v.y;
        z = v.z;
    }

    public Vector3f(float x, float y, float z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    void normalize() {
        float total = length();
//        System.out.println("Normalising - "+toString()+" t:" + total);
        if(total != 0){
            x /= total;
            y /= total;
            z /= total;
        }
    }
   

    float lengthSquared(){
        return x*x+y*y+z*z;
    }
    
    float length() {
        return (float)Math.sqrt(lengthSquared());
    }

    void scale(float f) {
        x *= f;
        y *= f;
        z *= f;
    }
    
    void add(Vector3f v) {
        x += v.x;
        y += v.y;
        z += v.z;
    }
    
    void sub(Vector3f v) {
        x -= v.x;
        y -= v.y;
        z -= v.z;
    }
    

    void negate() {
        x = -x;
        y = -y;
        z = -z;
    }

    @Override
    public String toString() {
        return "Vector (" + x +"," + y + ","+z+")";
    }
    
    
    
}
